package com.bytz.modules.cms.reseller.controller;

import com.bytz.common.api.vo.Result;
import com.bytz.modules.cms.reseller.model.EndUserModel;
import com.bytz.modules.cms.reseller.model.SearchEndUserModel;
import com.bytz.modules.cms.reseller.service.IMallEndUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "终端用户")
@RequestMapping("/endUser")
public class EndUserController {

    @Autowired
    private IMallEndUserService endUserService;

    @ApiOperation("获取经销商所有end user")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<List<EndUserModel>> endUserList() {

        return Result.ok(endUserService.getEndUserList());
    }

    @ApiOperation(value = "终端用户查询", notes = "只有在精准匹配到一条终端用户时才会返回")
    @RequestMapping(value = "/searchEndUser", method = RequestMethod.GET)
    public Result<SearchEndUserModel> searchEndUser(@RequestParam String condition) {

        return Result.ok(endUserService.searchEndUser(condition));
    }

}
